#ifndef MMOVEL
#define MMOVEL

#include <math.h>
#include "messages.h"

class mmovel
{
private:
	double val[400];
	int i,num,total;
public:
	double medm;
	void addvalue(double value);
	void init(int t);
	~mmovel(void);
};

mmovel::~mmovel(void)
{
}

void mmovel::init(int t)
{
	total=t;
	i=0;
	num=0;
	medm=0;
}

void mmovel::addvalue(double value)
{
	if(num<total)
	{
		medm = (i*(medm)+value)/(i+1);
		val[num]=value;
		num++;
		i=num;
		if(i==total) i=0;
	}
	else
	{
		medm = medm + (value-val[i])/total;
		val[i]=value;
		i++;
		if(i==total) i=0;
	}
}

#endif
